package org.example.tree;

public class ArrBinaryTree {

    private int[] arr;

    public ArrBinaryTree(int[] arr) {
        this.arr = arr;
    }

    public void preOrder(){
        this.preOrder(0);
    }

    public void preOrder(int n){

        if (arr ==null || arr.length == 0){
            System.out.println("数组为空");
        }

        System.out.println(arr[n]);
        if (2*n + 1 < arr.length){
            preOrder(2*n + 1);
        }
        if (2*n + 2 < arr.length){
            preOrder(2*n + 2);
        }

    }

}
